package com.erp.erp_ui.CustomerPool;

import com.erp.erp_entitys.CustomerPool.CustomerPoolEntity;
import com.erp.erp_servers.CustomerPool.ICustomerPoolService;
import com.erp.utils.R;
import com.erp.utils.ResultStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 客户公共池
 * @ClassName CustomerPoolControl
 * @Description TODO
 * @Author songjizhen
 * @Date 2020-07-03 23:07
 * @Version 1.0
 */
@Controller
@RequestMapping(value = "customerpool")
public class CustomerPoolControl {
    @Autowired
    ICustomerPoolService customerPoolService;

    @RequestMapping(value = "insertorupdate",method = RequestMethod.POST)
    @ResponseBody
    public R<Integer> insertorupdate(@RequestBody CustomerPoolEntity record){
        //int insert(CustomerPoolEntity record);
        try{
            int num=0;
           if(!(record.getId()==null)){
               num= customerPoolService.updateByPrimaryKey(record);
            }else{
                num= customerPoolService.insert(record);
           }
           return R.build(num);
        }catch (Exception e){
            e.printStackTrace();
            return R.buildError(ResultStatusEnum.ERROR);
        }
    }
}
